package com.kx.springboot;

import com.kx.springboot.service.StudentService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Springboot026Java1Application {

    public static void main(String[] args) {
        /**
         * SpringBoot程序启动后，返回值是ConfigurableApplicationContext，它也是一个Spring容器
         * 相当于Spring原来Spring容器中启动容器ClasspathXmlApplicationContext
         */
        //获取SpringBoot容器
        ConfigurableApplicationContext cac = SpringApplication.run(Springboot026Java1Application.class, args);
        //从容器中获取指定bean对象
        StudentService studentService = (StudentService) cac.getBean("studentServiceImpl");
        String str = studentService.sayHello();
        System.out.println(str);
    }

}
